<template>
  <a-modal
    title="安排面试"
    :width="320"
    :maskClosable = "false"
    :visible="visible"
    :confirmLoading="loading"
    @ok="ok"
    @cancel="() => { $emit('cancel') }"
  >
    <a-spin :spinning="loading">
      <a-form :form="form" v-bind="layout">
        <a-form-item label="面试编号">
          <a-input-number :min="1"
                          v-decorator="['id', { rules: [{ required: true, message: '请输入面试编号' }] }]" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      required: true
    },
    loading: {
      type: Boolean,
      default: () => false
    }
  },
  data () {
    return {
      form: this.$form.createForm(this),
      layout: {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 7 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 13 }
        }
      }
    }
  },
  methods: {
    ok() {
      this.form.validateFields((errors, values) => {
        if (!errors) {
          this.$emit('ok', values.id)
        }
      })
    }
  }
}
</script>
